package agent.client.android.behaviours;

import jade.core.behaviours.OneShotBehaviour;
import jade.lang.acl.ACLMessage;

import java.io.IOException;
import java.util.logging.Logger;

import agent.client.android.utils.GetAID;

/**
 * Bheaviour che invia una rischiesta di appuntamento
 */
public class RequestAppointmentBehaviour extends OneShotBehaviour {

	private static final long serialVersionUID = 1L;

	private Logger logger = Logger.getLogger(this.getClass().getName());
	
	
	private String dataTransferObject;

	public RequestAppointmentBehaviour(String dataTransferObject) {

		this.dataTransferObject = dataTransferObject;
	}

	@Override
	public void action() {

		ACLMessage aclMessage = new ACLMessage(ACLMessage.REQUEST);
		aclMessage.setSender(myAgent.getAID());

		aclMessage.addReceiver(GetAID.aid(myAgent.getLocalName().replace("$mobile", "")));

		
		aclMessage.setContent(dataTransferObject);
		if(dataTransferObject==null)
			logger.info("DTO NULLO");
		else
			logger.info("DTO OK");

		myAgent.send(aclMessage);
	}	
}